var APP_USER_INFO_CACHE_KEY = "SAAS_IOT_USER_CACHE";
var UserInfoUtils = {
  /**
   * 保存用户信息
   * @param user
   * */
  setUserInfo: function (user) {
    if (user){
      var newUser = {
        id: user.id,
        username: user.username,
        number: user.number
      };
      var data = JSON.stringify(newUser);
      window.localStorage.setItem(APP_USER_INFO_CACHE_KEY, data);
    }
  },
  /**
   * 获取用户信息
   * @return {string}
   * */
  getUserInfo: function () {
    var user = window.localStorage.getItem(APP_USER_INFO_CACHE_KEY);
    if (user){
      return JSON.parse(user);
    }
    return null;
  }
};
export default UserInfoUtils;
